#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
const int N = 30;
int a[N], n, r;
bool vis[N];

void dfs(int x) {
	if (x > r) {
		for (int i = 1; i <= r; i++) {
			printf("%3d", a[i]);
		}
		cout << endl;
		return;
	}
	for (int i = 1; i <= n; i++) {
		if (!vis[i]&&i>a[x-1]) {
			vis[i] = true;
			a[x] = i;
			dfs(x + 1);
			vis[i] = false;
		}
	}
}

int main() {
	cin >> n >> r;
	dfs(1);
	return 0;
}